﻿using Newtonsoft.Json;
using Senparc.Weixin.MP.Containers;
using Senparc.Weixin.MP.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZBJF.Warranty.Common.Common;

namespace ZBJF.Warranty.WeiXin
{
    public class JsApiHelper
    {
        #region 获取JsApi的Ticket + static string GetJsApiTicket()
        /// <summary>
        /// 获取JsApi的Ticket
        /// </summary>
        /// <returns></returns>
        public static string GetJsApiTicket()
        {
            return JsApiTicketContainer.TryGetJsApiTicket(WeiXinConfig.APPID, WeiXinConfig.APPSECRET);
        }
        #endregion

        #region MyRegion + JsSdkUiPackage GetJsSdkUiPackage(string url)
        /// <summary>
        /// 获取JsApi的请求实体
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JsSdkUiPackage GetJsSdkUiPackage(string url)
        {
            JsSdkUiPackage result= JSSDKHelper.GetJsSdkUiPackage(WeiXinConfig.APPID, WeiXinConfig.APPSECRET, url);

            LogHelper.WriteLog(url+";获取jsapi分享参数：" +JsonConvert.SerializeObject(result), LogType.remark);

            return result;
        } 
        #endregion
    }
}
